<template>
  <div class="invite-item invite-item2" :style="mode == 'own' ? 'height:auto' : ''" @click.stop>
    <div @click.stop="details(item)">
      <div class="invite-view-time" v-if="item.createDate && from == 'view'">
        {{ item.createDate.split(" ")[0] }}
      </div>
      <div class="invite-item-top line1">
        {{ item.resumeTitle }}
        <!-- 真诚求职一份工作真诚求职一份工作真诚求职一份工作标题（标题三十五个字） -->
        <div class="redDain" v-if="item.receivingStatus != 1 && mode == 'own'"></div>
      </div>
      <div class="invite-item-middle">
        <span v-for="(item, index) in (item.intendedPosition || '')
          .split('|')
          .filter((item) => item)" :key="item + index">
          {{ item }}</span>
        <!-- <span>电子数据取证分析师</span>
        <span>办公室文员</span>
        <span>服务机器人应用技术人员</span>
        <span>保洁员</span> -->
      </div>
    </div>

    <div>
      <div class="invite-item-bottom " :ref="'recommend' + count">
        <img :src="(item.userInformation && item.userInformation.image) ||
          (item.userInformationDto && item.userInformationDto.image) ||
          defaultAvatar
          " alt="" @click.stop="agentDetailNew(item)" />
        <div class="invite-name" @click.stop="agentDetailNew(item)">
          <!-- 王依依 -->
          {{
            item.userInformation && item.userInformation.nikeName ||
            (item.userInformationDto && item.userInformationDto.nikeName) ||
            "未命名用户"
          }}
        </div>
        <div class="invite-vip" :style="{
              color:
                colors[(item.userInformation.memberLevel || 1) - 1].wordColor,
              backgroundColor:
                colors[(item.userInformation.memberLevel || 1) - 1].bgColor,
              borderColor:
                colors[(item.userInformation.memberLevel || 1) - 1].lineColor,
            }">
          <!-- 青铜会员 -->
          {{ colors[item.userInformation.memberLevel || 1 - 1].level }}
          <!-- {{ item.memberTitle }} -->
        </div>
        <div class="marks ">
          {{ item.experienceYears }}工作经验
          <div class="marks-seperate"></div>
        </div>
        <div class="marks ">
          <!-- 大专 -->
          {{ item.highestEducation }}
          <div class="marks-seperate"></div>
        </div>
        <!-- <div class="marks gray " :class="showLine1 ? 'line1' : ''" v-if="item.homeAddress">
          {{ item.homeAddress }}

          <div class="marks-seperate"></div>
        </div>
        <div class="marks gray " :class="[showLine2 ? 'line1' : '', showHide1 ? 'display-no' : '']"
          :ref="'recommend-sub' + count" v-if="item.distance && item.latitude">
      
          {{ item.distance }}km

          <div class="marks-seperate"></div>
        </div> -->
      </div>
      <div class="invite-bottom" v-if="mode == 'own'">
        <div class="invite-user-post-time-wrap">
          <div class="invite-user-post-time-wrap">
            <div class="invite-user-post-time">
              投递时间：{{ $time.getDateDiff(item.createDate) }}
            </div>
            <div class="invite-user-post-time" style="margin-left: 24px">
              投递岗位：{{ item.recruitmentInformationDTO.positionCategory }}
            </div>
          </div>

          <!-- <div class="invite-user-post-btn">简历记录</div> -->
        </div>
      </div>
    </div>
  </div>
</template>

<script>
var count = 10086
export default {
  props: {
    item: {
      type: Object,
      default() {
        return {};
      },
    },
    mode: {
      type: String,
      default() {
        return "";
      },
    },
    from: {
      type: String,
      default: "show", // show展示 view浏览
    },
    // 自定义事件
    customEvent: {
      type: Boolean,
      default: false,
    },
  },
  watch: {
    item: {
      handler(newV, oldV) {
        if (JSON.stringify(newV) != "{}") {
          this.count = ++count;


          newV.homeAddress = (newV.homeAddress || '').replace(/山东省/g, '').replace(/青岛市/g, '').replace(/平度市/g, '')
          this.$nextTick(function () {
            var ref = this.$refs['recommend' + this.count]
            var ref2 = this.$refs['recommend-sub' + this.count]
            if (ref2) {
              var containerWidth = window.getComputedStyle(ref).width
              containerWidth = containerWidth.substring(0, containerWidth.length - 3)
              var itemWidth = window.getComputedStyle(ref2).width
              itemWidth = itemWidth.substring(0, itemWidth.length - 3)

              var ScollWidth = ref.scrollWidth
              // console.log('scrollWidth', this.count, ScollWidth, itemWidth, containerWidth, ScollWidth - itemWidth)
              // return
              if (ScollWidth > containerWidth) {
                if (ScollWidth - itemWidth > containerWidth) {
                  this.showLine1 = true
                  this.showHide1 = true
                } else {
                  this.showLine2 = true

                }
              }
            } else {
              this.showLine1 = true
            }

            // console.log('ref', window.getComputedStyle(ref).width)
            // console.log('ref', ref.scrollWidth)


          })
          // window.getComputedStyle(dom).width
          // invite-item-bottom
        }
      },
      immediate: true
    }



  },
  created() {
  },
  data() {
    return {
      showHide1: false,
      showLine1: false,
      showLine2: false,
      count: 0,
      colors: [
        {
          bgColor: "#E9EFEF",
          wordColor: "#60807D",
          lineColor: "#B6C4C3",
          level: "青铜会员",
        },
        {
          bgColor: "#F7F7F7",
          wordColor: "#A3AAB0",
          lineColor: "#D2D9E0",
          level: "白银会员",
        },
        {
          bgColor: "#FFF8DE",
          wordColor: "#CEAB21",
          lineColor: "#D3CAB2",
          level: "黄金会员",
        },
        {
          bgColor: "#EDFAFF",
          wordColor: "#59B0E6",
          lineColor: "#BBD0DB",
          level: "铂金会员",
        },
        {
          bgColor: "#F2F5FF",
          wordColor: "#284EB6",
          lineColor: "#C1CBEF",
          level: "钻石会员",
        },
        {
          bgColor: "#FDF7FF",
          wordColor: "#A877C6",
          lineColor: "#DBC6E8",
          level: "钻石Ⅰ会员",
        },
        {
          bgColor: "#F8F2FF",
          wordColor: "#78439F",
          lineColor: "#958AC3",
          level: "钻石Ⅱ会员",
        },
        {
          bgColor: "#F4F2F2",
          wordColor: "#8D4581",
          lineColor: "#907B8C",
          level: "钻石Ⅲ会员",
        },
        {
          bgColor: "#F4F2F2",
          wordColor: "#502E30",
          lineColor: "#795D5E",
          level: "王者会员",
        },
      ],
    };
  },
  methods: {
    details(item = this.item) {
      if (this.customEvent) {
        this.$emit("details", item);
      } else {
        var query = {};
        if (item.auditStatus == 0) {
          // 待审核
          this.goResumeOne(
            {
              id: item.id,
              type: "audit",
            },
            item
          );
        } else {
          this.goResumeOne(
            {
              id: item.id,
            },
            item
          );
        }
      }
    },
  },
};
</script>

<style lang="less" scoped>
.display-no {
  display: none !important;
}

.invite-view-time {
  display: block;
  padding: 6px 0;
  width: 100px;
  text-align: center;
  white-space: nowrap;
  background-color: #c4c4c4;
  border-radius: 2px;
  color: #fff;
}

.invite-bottom {
  padding-bottom: 16px;
}

.invite-item {
  overflow: hidden;
  width: 100%;
  max-width: 1200px;
  opacity: 1;
  border-bottom: 1px solid #f2f2f2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 0;
  height: 126px;
  cursor: pointer;

  div {
    .invite-item-top {
      height: 34px;
      font-size: 24px;
      font-weight: 500;
      color: #333333;
      line-height: 34px;
      margin-bottom: 10px;
      position: relative;

      .redDain {
        position: absolute;
        right: 5px;
        top: 5px;
        width: 8px;
        height: 8px;
        border-radius: 8px;
        background-color: red;
      }
    }

    .invite-item-middle {
      height: 28px;
      font-size: 20px;
      font-weight: 400;
      color: #333333;
      line-height: 28px;

      span {
        margin-right: 20px;
      }
    }
  }

  .invite-item-bottom {
    display: flex;
    align-items: center;

    img {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      background: #d9d9d9;
      opacity: 1;
      margin-right: 4px;
      flex-shrink: 0;
      display: inline-block;
      vertical-align: middle;
    }

    .invite-name {
      font-size: 20px;
      font-weight: 400;
      color: #333333;
      margin-right: 4px;
      white-space: nowrap;
      cursor: pointer;
      display: inline-block;
      vertical-align: middle;
    }

    .invite-vip {
      display: inline-block;
      vertical-align: middle;
      padding: 0 3px;
      margin-right: 20px;
      white-space: nowrap;
      line-height: 24px;
    }

    .marks {

      font-size: 18px;
      font-weight: 400;
      color: #333333;
      display: flex;
      align-items: center;
      justify-content: center;
      white-space: nowrap;
      display: inline-block;
      vertical-align: middle;

      &:last-child {
        .marks-seperate {
          display: none;
        }
      }

      &.gray {
        color: #999999;
      }

      .marks-seperate {
        display: inline-block;
        vertical-align: middle;
        width: 2px;
        height: 25px;
        opacity: 1;
        background-color: #999999;
        margin: 0 10px;
      }
    }
  }
}

.invite-user-post-time-wrap {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;

  .invite-user-post-time {
    height: 28px;
    font-size: 20px;
    font-weight: 400;
    color: #333333;
    line-height: 28px;
  }

  .invite-user-post-btn {
    text-align: center;
    width: 112px;
    height: 40px;
    border-radius: 4px;
    opacity: 1;
    border: 1px solid #64b6a8;

    text-align: center;
    height: 28px;
    font-size: 20px;
    font-weight: 400;
    color: #64b6a8;
    line-height: 28px;
    cursor: pointer;
  }
}
</style>
